import request from '@/utils/request'
import type{ QueryParams, RuleForm } from "@/views/dish/list/types";
// 查询所有菜品
export function listAllDish() {
  return request({
    url: '/dish/listAll',
    method: 'get'
  })
}

// 查询菜品列表
export function listDish(query: QueryParams) {
  return request({
    url: '/dish',
    method: 'get',
    params: query
  })
}

// 分页查询菜品列表
export function listDishByPage(query: QueryParams) {
  return request({
    url: '/dish/page',
    method: 'get',
    params: query
  })
}

//根据id查询菜品
export function getDishById(dishId: number) {
  return request({
    url: '/dish/' + dishId,
    method: 'get'
  })
}

// 根据dishName查询菜品
export function getDishByName(dishName: string) {
  return request({
    url: '/dish/' + dishName,
    method: 'get'
  })
}

// 根据分类查询菜品
export function getDishByCategory(category: string) {
  return request({
    url: '/dish/getByCategory/' + category,
    method: 'get'
  })
}

// 新增菜品
export function addDish(data: RuleForm) {
  return request({
    url: '/dish',
    method: 'post',
    data: data
  })
}

// 修改菜品
export function updateDish(data: RuleForm) {
  return request({
    url: '/dish',
    method: 'put',
    data: data
  })
}

// 删除菜品
export function deleteDish(dishId: number) {
  return request({
    url: '/dish/' + dishId,
    method: 'delete'
  })
}

// 批量删除菜品
export function deleteDishBatch(dishIds: number[]) {
  return request({
    url: '/dish/delBatch/' + dishIds,
    method: 'delete'
  })
}
